package thread.lock.reentral_condition_base;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by mHandler on 2018/6/3 0003.
 * Description:
 */
public class MyService {
    private ReentrantLock lock = new ReentrantLock();
    private Condition condition = lock.newCondition();

    public void await(){
        try {
            lock.lock();
            System.out.println("await时间："+System.currentTimeMillis());
            condition.await();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            lock.unlock();
        }
    }

    public void signal(){
        try {
            lock.lock();
            System.out.println("signal时间："+System.currentTimeMillis());
            condition.signal();
        } finally {
            lock.unlock();
        }
    }
}
